package cn.mg.framework.util.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ezhong
 */
public class MapBuilder<K, V> {

    public Builder<K, V> b;

    public MapBuilder(Builder<K, V> b){
        this.b = b;
    }

    public Map<K, V> build(){
        return b.map;
    }

    public V get(K key){
        return b.map.get(key);
    }

    public MapBuilder.Builder<K, V> put(K key, V value){
        b.map.put(key, value);
        return b;
    }

    public static class Builder<K, V>{

        public Map<K, V> map;

        public Builder(){
            map = new HashMap<K, V>();
        }

        public MapBuilder<K, V> build(){
            return new MapBuilder<K, V>(this);
        }

        public MapBuilder.Builder<K, V> put(K key, V value) {
            map.put(key, value);
            return this;
        }
    }
}


